﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;

namespace WXYW
{
    public partial class AllReturnToFactoryRecords : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindForms();
            }
        }

        private void BindForms()
        {
            ReturnToFactoryService service = new ReturnToFactoryService();
            returnToFactoryGridView.DataSource = service.GetReturnToFactoryFormsByKeywords(keyWordTextBox.Text);
            returnToFactoryGridView.DataBind();
        }

        protected void searchLinkButton_Click(object sender, EventArgs e)
        {
            BindForms();
        }

        protected void resetLinkButton_Click(object sender, EventArgs e)
        {
            keyWordTextBox.Text = string.Empty;
            BindForms();
        }

        protected void viewLinkButton_Click(object sender, EventArgs e)
        {
            string returnToFactoryID = ((LinkButton)sender).CommandArgument;
            Response.Redirect(string.Format("ReturnToFactoryRecordDetail.aspx?{0}={1}", Constants.QUERYSTR_RETURNTOFACTORY_ID, returnToFactoryID));
        }

        protected void maintainProductGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            if (e.NewPageIndex >= 0 && e.NewPageIndex < returnToFactoryGridView.PageCount)
            {
                returnToFactoryGridView.PageIndex = e.NewPageIndex;
            }
            
            BindForms();
        }
    }
}
